home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / pdrd2.zip / RD.ZIP / RD_DEMO3.PRG < prev    next >
Text File  |  1993-01-11  |  3KB  |  89 lines

  1. /*
  2.     RD_DEMO3.PRG
  3.  
  4.     Demonstrates the following APIs:
  5.     1. ADr_popup() - pops up a picklist of valid Get values.
  6.     2. ADr_required() - disallows leaving an empty Get.
  7.     3. ADr_jump() - moves the focus to a specified Get.
  8.     4. ADr_blank() - blanks specific Gets.
  9.     5. ADr_keys() - defines hot keys.
  10. */
  11.  
  12. #include "read.ch"
  13. #include "inkey.ch"
  14.  
  15. //---------
  16. func main()
  17. local aPayModes := { "Cash       ",;
  18.                      "Credit Card",;
  19.                      "Check      " }
  20. local aCards := { "Visa      ",;
  21.                   "MasterCard",;
  22.                   "Discover  " }
  23. local getlist[0]
  24. local cPayMode := space(11)
  25. local cCardType := space(10)
  26. local cCardNumber := space(16)
  27. local nAmount := 0
  28. local nT := 10, nL := 10, nB := 15, nR := 42
  29. local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
  30. local aScn, aScn2
  31. local bConfig := {|e| ADr_keys( e,;
  32.                                 {K_ALT_F1, K_F10},;
  33.                                 {|e,nth,nkey| Xkeys3(e,nth,nkey,aPayModes,aCards)};
  34.                               );
  35.                   }
  36.  
  37. cls
  38. aScn = ADbox( nT, nL, nB, nR )
  39. aScn2 = ADmessage( {;
  40.                         "Popups are attached to 'Payment mode' and 'Card type'.",;
  41.                         "Activate them by pressing ALT-F1 or by keying in an invalid",;
  42.                         "entry.",;
  43.                         "You may also press F10 to blank all Gets";
  44.                    },;
  45.                    18,, .f., .f.;
  46.                  )
  47. @nT+1, nL+2 say "Payment mode" adget cPayMode;
  48.                                valid {|e,_x| _x := ADr_popup( e, row()+1, col()+3, aPayModes, {4,11,5} ),;
  49.                                              _x != 0 }
  50. @nT+2, nL+2 say "Card type   " adget cCardType;
  51.                                valid {|e| ADr_popup( e, row()+1, col()+3, aCards ) > 0};
  52.                                when ( cPayMode == "Credit Card" )
  53. @nT+3, nL+2 say "Card number " adget cCardNumber;
  54.                                valid {|e| ADr_required(e)};
  55.                                when ( cPayMode == "Credit Card" )
  56. @nT+4, nL+2 say "Amount      " adget nAmount picture "99999.99"
  57. ADread( getlist, bConfig )
  58. ADrestscn( aScn2 )
  59. ADrestscn( aScn )
  60. setcolor( cColor )
  61. return nil
  62.  
  63. //------------------------------------------
  64. func Xkeys3( e, nth, nkey, aPayMode, aCards )
  65. if nkey = K_ALT_F1
  66.     Xpopup3( e, aPayMode, aCards )
  67. elseif nkey = K_F10
  68.     ADr_blank( e, {} )
  69.     ADr_jump( e, 1, .t. )
  70. endif
  71. return nil
  72.  
  73.  
  74. //-------------------------------
  75. func Xpopup3(e, aPayModes, aCards)
  76. local nthGet := ADr_nthget(e)
  77.  
  78. if nthGet = 1
  79.     ADr_popup( e, row()+1, col()+3, aPayModes, {4,11,5}, .t. )
  80. elseif nthGet = 2
  81.     ADr_popup( e, row()+1, col()+3, aCards,, .t. )
  82. else
  83.     tone(100,1)
  84. endif
  85. return nil
  86.  
  87.  
  88.  
  89.